package com.yycx.module.bus.provider.service.hy;

import com.yycx.common.base.entity.EntityMap;
import com.yycx.common.mybatis.base.service.IBaseService;
import com.yycx.common.mybatis.model.ResultBody;
import com.yycx.module.bus.client.entity.BusSaleman;
import com.yycx.module.bus.client.entity.hy.HyOrder;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 非两票订单 接口
 *
 * @author flyme
 * @date 2020-07-28
 */
public interface HyOrderService extends IBaseService<HyOrder> {
    /**
     * 初始化海鹰订单到系统
     *
     * @param dbName
     * @param orderNo
     * @return
     */
    ResultBody syncOrder(String dbName, String orderNo);

    /**
     * 根据订单号查询
     *
     * @param orderNo
     * @return
     */
    HyOrder getByOrderNo(String orderNo);

    HyOrder getOutOrderNo(String orderNo,Long companyId);

    /**
     * 查询退货单
     *
     * @param orderId
     * @return
     */
    List<HyOrder> getBackOrder(String orderId);

    /**
     * 查询订单信息
     *
     * @param orderId
     * @return
     */
    EntityMap getMapByOrderId(String orderId);

    /**
     * 更新订单状态
     *
     * @param orderId
     * @param processInstanceId
     * @param orderState
     * @param revokeState
     * @param syncTag
     * @return
     */
    Boolean updateOrderState(Serializable orderId, String processInstanceId, Integer orderState, Integer revokeState, Integer syncTag, Date createDate);

    /**
     * 更新订单状态
     *
     * @param orderId
     * @param processInstanceId
     * @param orderState
     * @param revokeState
     * @param syncTag
     * @return
     */
    Boolean updateOrderState(Serializable orderId, String processInstanceId, Integer orderState, Integer revokeState, Integer syncTag);


    /**
     * 更新订单状态
     *
     * @param orderId
     * @param orderState
     * @return
     */
    Boolean updateOrderState(Serializable orderId, Integer orderState);


    /**
     * 申请撤销流程
     *
     * @param orderId
     * @return
     */
    Boolean revokeProcess(String orderId);

    /**
     * 删除退货单
     *
     * @param orderId
     * @param parentId
     * @return
     */
    Boolean deleteBackOrder(String orderId,String parentId);


    /**
     * 同步订单发货状态
     *
     * @return
     */
    Boolean syncSendState();


    /**
     * 同步订单到海鹰系统
     *
     * @return
     */
    Boolean syncInsertOrder();

    /**
     * 同步退货单
     *
     * @return
     */
    Boolean syncBackOrder();

    /**
     * 更改发货状态
     *
     * @param orderId
     * @param outOrderMap
     * @return
     */
    Boolean updateSendState(String orderId, Map outOrderMap);

    /**
     * 退补差价
     * @param orderId
     * @param drugList
     * @return
     */
    Boolean saveTuibu(String orderId,String drugList);

    /**
     * 保存退货
     * @param orderId
     * @param returnList
     * @param reason
     * @return
     */
    Boolean saveBack(String orderId, String reason,String returnList);
    /**
     * 取消申请撤销流程
     *
     * @param orderId
     * @return
     */
    Boolean cancelRevokeProcess(String orderId);

    /**
     * 取消开票申请
     *
     * @param orderId
     * @return
     */
    Boolean cancelInvoiceInfo(String orderId);

    /**
     * 更新订单核算状态
     *
     * @param orderId
     * @return
     */
    Boolean updateCaclulateOrder(String orderId, Integer status);


    /**
     * 修改订单核算为已核算
     *
     * @param orderId
     * @param applyIncId
     * @param status
     * @return
     */
    Boolean updateCaclulateOrder(String orderId, String applyIncId, Integer status);


    /**
     * 获取订单打印信息
     *
     * @param orderId
     * @return
     */
    ResultBody getPrintInfo(String orderId);

    /**
     * 获取出库单合并打印信息
     * @param orderId
     * @return
     */
    ResultBody getMergeOutOrderPrint(String orderId);

    /**
     * 获取出库单打印信息
     * @param orderId
     * @return
     */
    ResultBody getOutOrderPrint(String orderId);

    /**
     * 退货单打印信息
     *
     * @param orderId
     * @return
     */
    ResultBody getBackOrderPrintInfo(String orderId);


    /**
     * 更新打印次数
     *
     * @param orderId
     * @return
     */
    Boolean updatePrintTag(String orderId);

    /**
     * 更新打印次数
     *
     * @param orderId
     * @return
     */
    Boolean updateOutPrintTag(String orderId);


    /**
     * 更新标签打印
     * @param orderId
     * @return
     */
    Boolean updateOutPrintTag2(String orderId);


    /**
     * 设置是否需要打印出库单
     * @param orderId
     * @param outPrintTag
     * @return
     */
    Boolean setOutPrintTag(String orderId,Integer outPrintTag);


    /**
     * 设置标签打印
     * @param orderId
     * @param outPrintTag2
     * @return
     */
    Boolean setOutPrintTag2(String orderId, Integer outPrintTag2);

    List<HyOrder> getOrderList(String orderId);

    /**
     * 申请开货款发票
     *
     * @param orderId
     * @param invoiceSendType
     * @param invoiceRemark
     * @return
     */
    Boolean updateOrderInvoiceInfo(String orderId, Integer invoiceSendType, String invoiceRemark);


    /**
     * 查询未提单订单
     *
     * @param sendState
     * @return
     */
    List<HyOrder> selectBySendState(Integer sendState);

    /**
     * 更新开票状态
     *
     * @param orderId
     * @return
     */
    Boolean updateInvoiceState(String orderId,Integer invoiceState);


    /**
     * 查询某个业务员客户对应的最后一次发货信息
     * @param saleManId
     * @param customId
     * @return
     */
    HyOrder selectLastOrderByCustomId(Long saleManId, Long customId);

    BusSaleman checkOrder(HyOrder hyOrder, Boolean isAdd, Integer historyOrder);

    void setHyOrderInfo(HyOrder hyOrder, BusSaleman saleMan);

    void saveOrderDetails(HyOrder hyOrder, String drugList, Boolean isAdd);

}
